package com.fuhao.springbootrabbit.config.topic;

import com.fuhao.springbootrabbit.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhang
 * @title: TopicConfig
 */
@Configuration
public class TopicConfig {

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(RabbitConstant.TOPIC_EXCHANGE_NAME);
    }

    @Bean
    public Queue queue3(){
        return new Queue(RabbitConstant.TOPIC_QUEUE1_NAME);
    }

    @Bean
    public Queue queue4(){
        return new Queue(RabbitConstant.TOPIC_QUEUE2_NAME);
    }

    @Bean
    public Binding binding3(){
        return BindingBuilder.bind(queue3()).to(topicExchange()).with(RabbitConstant.TOPIC_ROUTE_KEY1_NAME);
    }

    @Bean
    public Binding binding4(){
        return BindingBuilder.bind(queue4()).to(topicExchange()).with(RabbitConstant.TOPIC_ROUTE_KEY2_NAME);
    }
}
